/* $Id: ServiceLocatorImpl.java 
 * Copyright (C) 2011, TRAKHEES
 *  
 * Revision History
 *
 * Date  			Author 		    	Remarks
 * ---------------------------------------------------------------------------------
 *
 */
package ae.pcfc.etks.online.common.service.provider;

import ae.pcfc.etks.online.common.exception.LocatorException;
import ae.pcfc.etks.online.common.facade.AdminClientCompanyReviewFacade;
import ae.pcfc.etks.online.common.facade.AdminClientPersonReviewFacade;
import ae.pcfc.etks.online.common.facade.AdminNonClientCompanyReviewFacade;
import ae.pcfc.etks.online.common.facade.AdminNonClientPersonReviewFacade;
import ae.pcfc.etks.online.common.facade.AppMetaDataFacade;
import ae.pcfc.etks.online.common.facade.AttachmentTypeFacade;
import ae.pcfc.etks.online.common.facade.ClientRegistrationFacade;
import ae.pcfc.etks.online.common.facade.Facade;
import ae.pcfc.etks.online.common.facade.NonClientCompanyRegisterFacade;
import ae.pcfc.etks.online.common.facade.NonClientPersonRegisterFacade;
import ae.pcfc.etks.online.common.facade.ProcessStepAttachmentFacade;
import ae.pcfc.etks.online.common.facade.SecretQuestionFacade;
import ae.pcfc.etks.online.common.facade.ServiceFacade;
import ae.pcfc.etks.online.common.facade.UserFacade;
import ae.pcfc.etks.online.common.facade.UserReqFacade;
import ae.pcfc.etks.online.common.facade.UserRoleFacade;
import ae.pcfc.etks.online.common.facade.UtilityFacade;
import ae.pcfc.etks.online.common.manager.MailManager;
import ae.pcfc.etks.online.common.manager.Manager;
import ae.pcfc.etks.online.common.manager.ReportManager;
import ae.pcfc.etks.online.common.service.ServiceLocator;
import ae.pcfc.etks.online.wf.service.client.BaseWF;
import ae.pcfc.etks.online.wf.service.client.ClientRoleWF;
import ae.pcfc.etks.online.wf.service.client.UserServiceWF;
import ae.pcfc.etks.online.wf.service.client.provider.ClientCompanyAdminWFImpl;
import ae.pcfc.etks.online.wf.service.client.provider.ClientPersonAdminWFImpl;
import ae.pcfc.etks.online.wf.service.client.provider.NonClientCompanyWFImpl;
import ae.pcfc.etks.online.wf.service.client.provider.NonClientPersonWFImpl;

public class ServiceLocatorImpl implements ServiceLocator {

	private MailManager mailManager;

	private ReportManager reportManager;

	private ClientRegistrationFacade clientRegistrationFacade;

	private UserReqFacade userReqFacade;

	private NonClientPersonRegisterFacade nonClientPersonRegisterFacade;

	private ServiceFacade serviceFacade;

	private AdminClientPersonReviewFacade adminClientPersonReviewFacade;

	private NonClientCompanyRegisterFacade nonClientCompanyRegisterFacade;

	private AdminNonClientCompanyReviewFacade adminNonClientCompanyReviewFacade;

	private AdminClientCompanyReviewFacade adminClientCompanyReviewFacade;

	private UserFacade userFacade;

	private AdminNonClientPersonReviewFacade adminNonClientPersonReviewFacade;

	private AttachmentTypeFacade attachmentTypeFacade;

	private UtilityFacade utilityFacade;

	private AppMetaDataFacade appMetaDataFacade;

	private SecretQuestionFacade secretQuestionFacade;
	
	private ProcessStepAttachmentFacade processStepAttachmentFacade;
	
	private ClientRoleWF clientRoleWF;
	
	private UserServiceWF userServiceWF;
	
	private NonClientCompanyWFImpl nonClientCompanyWF;
	
	private NonClientPersonWFImpl nonClientPersonWF;
	
	private ClientCompanyAdminWFImpl clientCompanyAdminWF;
	
	private ClientPersonAdminWFImpl clientPersonAdminWF;
	
	//private UserAnnouncementFacade userAnnouncementFacade;

	public UserServiceWF getUserServiceWF() {
		return userServiceWF;
	}

	public void setUserServiceWF(UserServiceWF userServiceWF) {
		this.userServiceWF = userServiceWF;
	}

	public NonClientCompanyWFImpl getNonClientCompanyWF() {
		return nonClientCompanyWF;
	}

	public void setNonClientCompanyWF(NonClientCompanyWFImpl nonClientCompanyWF) {
		this.nonClientCompanyWF = nonClientCompanyWF;
	}

	public NonClientPersonWFImpl getNonClientPersonWF() {
		return nonClientPersonWF;
	}

	public void setNonClientPersonWF(NonClientPersonWFImpl nonClientPersonWF) {
		this.nonClientPersonWF = nonClientPersonWF;
	}

	public ClientCompanyAdminWFImpl getClientCompanyAdminWF() {
		return clientCompanyAdminWF;
	}

	public void setClientCompanyAdminWF(
			ClientCompanyAdminWFImpl clientCompanyAdminWF) {
		this.clientCompanyAdminWF = clientCompanyAdminWF;
	}

	public ClientPersonAdminWFImpl getClientPersonAdminWF() {
		return clientPersonAdminWF;
	}

	public void setClientPersonAdminWF(ClientPersonAdminWFImpl clientPersonAdminWF) {
		this.clientPersonAdminWF = clientPersonAdminWF;
	}

	public ClientRoleWF getClientRoleWF() {
	    return clientRoleWF;
	}

	public void setClientRoleWF(ClientRoleWF clientRoleWF) {
	    this.clientRoleWF = clientRoleWF;
	}

	/**
	 * setSecretQuestionFacade
	 * 
	 * @param secretQuestionFacade
	 * void
	 */
	public void setSecretQuestionFacade(SecretQuestionFacade secretQuestionFacade) {
		this.secretQuestionFacade = secretQuestionFacade;
	}

	/**
	 * setClientRegistrationFacade
	 * 
	 * @param clientRegistrationFacade
	 * void
	 */
	public void setClientRegistrationFacade(ClientRegistrationFacade clientRegistrationFacade) {
		this.clientRegistrationFacade = clientRegistrationFacade;
	}

	/**
	 * setNonClientCompanyRegisterFacade
	 * 
	 * @param nonClientCompanyRegisterFacade
	 * void
	 */
	public void setNonClientCompanyRegisterFacade(NonClientCompanyRegisterFacade nonClientCompanyRegisterFacade) {
		this.nonClientCompanyRegisterFacade = nonClientCompanyRegisterFacade;
	}

	/**
	 * setAdminClientPersonReviewFacade
	 * 
	 * @param adminClientPersonReviewFacade
	 * void
	 */
	public void setAdminClientPersonReviewFacade(AdminClientPersonReviewFacade adminClientPersonReviewFacade) {
		this.adminClientPersonReviewFacade = adminClientPersonReviewFacade;
	}

	/**
	 * setNonClientPersonRegisterFacade
	 * 
	 * @param nonClientPersonRegisterFacade
	 * void
	 */
	public void setNonClientPersonRegisterFacade(NonClientPersonRegisterFacade nonClientPersonRegisterFacade) {
		this.nonClientPersonRegisterFacade = nonClientPersonRegisterFacade;
	}

	/**
	 * setServiceFacade
	 * 
	 * @param serviceFacade
	 * void
	 */
	public void setServiceFacade(ServiceFacade serviceFacade) {
		this.serviceFacade = serviceFacade;
	}

	/**
	 * setAdminNonClientCompanyReviewFacade
	 * 
	 * @param adminNonClientCompanyReviewFacade
	 * void
	 */
	public void setAdminNonClientCompanyReviewFacade(AdminNonClientCompanyReviewFacade adminNonClientCompanyReviewFacade) {
		this.adminNonClientCompanyReviewFacade = adminNonClientCompanyReviewFacade;
	}

	/**
	 * setAdminClientCompanyReviewFacade
	 * 
	 * @param adminClientCompanyReviewFacade
	 * void
	 */
	public void setAdminClientCompanyReviewFacade(AdminClientCompanyReviewFacade adminClientCompanyReviewFacade) {
		this.adminClientCompanyReviewFacade = adminClientCompanyReviewFacade;
	}

	/**
	 * setUserFacade
	 * 
	 * @param userFacade
	 * void
	 */
	public void setUserFacade(UserFacade userFacade) {
		this.userFacade = userFacade;
	}

	/**
	 * setAttachmentTypeFacade
	 * 
	 * @param attachmentTypeFacade
	 * void
	 */
	public void setAttachmentTypeFacade(AttachmentTypeFacade attachmentTypeFacade) {
		this.attachmentTypeFacade = attachmentTypeFacade;
	}

	/**
	 * setAdminNonClientPersonReviewFacade
	 * 
	 * @param adminNonClientPersonReviewFacade
	 * void
	 */
	public void setAdminNonClientPersonReviewFacade(AdminNonClientPersonReviewFacade adminNonClientPersonReviewFacade) {
		this.adminNonClientPersonReviewFacade = adminNonClientPersonReviewFacade;
	}

	/**
	 * setUtilityFacade
	 * 
	 * @param utilityFacade
	 * void
	 */
	public void setUtilityFacade(UtilityFacade utilityFacade) {
		this.utilityFacade = utilityFacade;
	}

	private UserRoleFacade userRoleFacade;

	/**
	 * setUserRoleFacade
	 * 
	 * @param userRoleFacade
	 * void
	 */
	public void setUserRoleFacade(UserRoleFacade userRoleFacade) {
		this.userRoleFacade = userRoleFacade;
	}

	/**
	 * setMailManager
	 * 
	 * @param mailManager
	 * void
	 */
	public void setMailManager(MailManager mailManager) {
		this.mailManager = mailManager;
	}

	/**
	 * setReportManager
	 * 
	 * @param reportManager
	 * void
	 */
	public void setReportManager(ReportManager reportManager) {
		this.reportManager = reportManager;
	}

	/**
	 * setUserReqFacade
	 * 
	 * @param userReqFacade
	 * void
	 */
	public void setUserReqFacade(UserReqFacade userReqFacade) {
		this.userReqFacade = userReqFacade;
	}

	/**
	 * setAppMetaDataFacade
	 * 
	 * @param appMetaDataFacade
	 * void
	 */
	public void setAppMetaDataFacade(AppMetaDataFacade appMetaDataFacade) {
		this.appMetaDataFacade = appMetaDataFacade;
	}
	
	/**
	 * setProcessStepAttachmentFacade
	 * 
	 * @param processStepAttachmentFacade
	 * void
	 */
	public void setProcessStepAttachmentFacade(ProcessStepAttachmentFacade processStepAttachmentFacade) {
		this.processStepAttachmentFacade = processStepAttachmentFacade;
	}
	
/*	public void setUserAnnouncementFacade(UserAnnouncementFacade userAnnouncementFacade) {
		this.userAnnouncementFacade = userAnnouncementFacade;
	}*/

	/**
	 * getManager
	 * 
	 * @see ae.pcfc.etks.online.common.service.ServiceLocator#getManager(java.lang.Class)
	 * 
	 */
	public <T extends Manager> T getManager(Class<T> type) throws LocatorException {

		if (type != null && type == MailManager.class && mailManager != null) {
			return type.cast(mailManager);
		} else if (type != null && type == ReportManager.class && reportManager != null) {
			return type.cast(reportManager);
		}

		throw new LocatorException("Unable to find Manager for class :" + type.getName());
	}

	/**
	 * getFacadeService
	 * 
	 * @see ae.pcfc.etks.online.common.service.ServiceLocator#getFacadeService(java.lang.Class)
	 * 
	 */
	public <T extends Facade> T getFacadeService(Class<T> type) throws LocatorException {
		if (type != null && type == ClientRegistrationFacade.class && clientRegistrationFacade != null) {
			return type.cast(clientRegistrationFacade);
		} else if (type != null && type == NonClientCompanyRegisterFacade.class && nonClientCompanyRegisterFacade != null) {
			return type.cast(nonClientCompanyRegisterFacade);
		} else if (type != null && type == NonClientPersonRegisterFacade.class && nonClientPersonRegisterFacade != null) {
			return type.cast(nonClientPersonRegisterFacade);
		} else if (type != null && type == ServiceFacade.class && serviceFacade != null) {
			return type.cast(serviceFacade);
		} else if (type != null && type == AdminNonClientCompanyReviewFacade.class && adminNonClientCompanyReviewFacade != null) {
			return type.cast(adminNonClientCompanyReviewFacade);
		} else if (type != null && type == AdminNonClientPersonReviewFacade.class && adminNonClientPersonReviewFacade != null) {
			return type.cast(adminNonClientPersonReviewFacade);
		} else if (type != null && type == AdminClientCompanyReviewFacade.class && adminClientCompanyReviewFacade != null) {
			return type.cast(adminClientCompanyReviewFacade);
		} else if (type != null && type == UserFacade.class && userFacade != null) {
			return type.cast(userFacade);
		} else if (type != null && type == AdminClientPersonReviewFacade.class && adminClientPersonReviewFacade != null) {
			return type.cast(adminClientPersonReviewFacade);
		} else if (type != null && type == UtilityFacade.class && utilityFacade != null) {
			return type.cast(utilityFacade);
		} else if (type != null && type == UserRoleFacade.class && userRoleFacade != null) {
			return type.cast(userRoleFacade);
		} else if (type != null && type == AttachmentTypeFacade.class && attachmentTypeFacade != null) {
			return type.cast(attachmentTypeFacade);
		} else if (type != null && type == UserReqFacade.class && userReqFacade != null) {
			return type.cast(userReqFacade);
		} else if (type != null && type == AppMetaDataFacade.class && appMetaDataFacade != null) {
			return type.cast(appMetaDataFacade);
		} else if (type != null && type == SecretQuestionFacade.class && secretQuestionFacade != null) {
			return type.cast(secretQuestionFacade);
		} else if (type != null && type == ProcessStepAttachmentFacade.class && processStepAttachmentFacade != null) {
			return type.cast(processStepAttachmentFacade);
		} /*else if (type != null && type == UserAnnouncementFacade.class && userAnnouncementFacade != null) {
			return type.cast(userAnnouncementFacade);
		}*/
		/*
		 * else if (type != null && type == ClientRegistrationFacade.class &&
		 * companyRegistrationFacade != null) { return
		 * type.cast(companyRegistrationFacade); }
		 */
		throw new LocatorException("Unable to find Facade Service for class :" + type.getName());
	}

	/**
	 * getWorkflowService
	 * 
	 * @see ae.pcfc.etks.online.common.service.ServiceLocator#getWorkflowService(java.lang.Class)
	 * 
	 */
	public <T extends BaseWF> T getWorkflowService(Class<T> type)
		throws LocatorException {
	    	if (type != null && type == ClientRoleWF.class && clientRoleWF != null) {
        		return type.cast(clientRoleWF);
        	} else if (type != null && type == UserServiceWF.class && userServiceWF != null) {
        		return type.cast(userServiceWF);
        	} else if (type != null && type == ClientCompanyAdminWFImpl.class && clientCompanyAdminWF != null) {
        		return type.cast(clientCompanyAdminWF);
        	} else if (type != null && type == ClientPersonAdminWFImpl.class && clientPersonAdminWF != null) {
        		return type.cast(clientPersonAdminWF);
        	} else if (type != null && type == NonClientCompanyWFImpl.class && nonClientCompanyWF != null) {
        		return type.cast(nonClientCompanyWF);
        	} else if (type != null && type == NonClientPersonWFImpl.class && nonClientPersonWF != null) {
        		return type.cast(nonClientPersonWF);
        	} 
        	throw new LocatorException("Unable to find Workflow for class :" + type.getName());
	}

	

}
